<?php
/*
 * @author : Thái Bảo Huy
 * @phone : 0937690850
 */
class Master extends CI_Controller{
    //put your code here

    public function  __construct() {
        parent::__construct();
        $this->load->helper("url");
		$this->load->helper('form');         
        $this->load->library("my_layout"); // Sử dụng thư viện layout
        $this->my_layout->setLayout("layout/midend"); // load file layout chính (view/layout/frontend.php)
    }

    // Controller mặc định cho trang chủ
    public function index(){
		$data['title'] = "HRS - Human Resource Management Website";
        $this->my_layout->view("master/v-home",$data);
    }  
	
	public function tinhcong(){
		$this->load->Model('m_nhanvien');
		$data['item'] = $this->m_nhanvien->person_info();
		$data['title']= "Chấm công";
		$this->my_layout->view("master/v-cong",$data);
	}
	
	public function chitietcong(){
		$this->load->Model('m_persondailylog');
		$data['item'] = $this->m_persondailylog->list_all();
		$data['title']= "Chi tiết ngày công";
		$this->my_layout->view("master/v-ctcong",$data);
	}
	public function tinhluong(){
	$this->load->Model('m_nhanvien');
		$data['item'] = $this->m_nhanvien->person_info();
		$data['title']= "Chấm lương";
		$this->my_layout->view("master/v-luong",$data);
	}		
	
	public function dskpi(){
		$data['title']= "Danh sách KPI";
		$this->load->Model('m_kpi');
		$data['item']= $this->m_kpi->list_all();		
		$this->my_layout->view("master/kpi",$data);
	}
	
	public function dsbckpi(){
		$data['title']= "Danh sách báo cáo KPI";
		$this->load->Model('m_ctkpi');
		$data['item']= $this->m_ctkpi->list_all();		
		$this->my_layout->view("master/v_kpi",$data);
	}
		
	public function xoakpi($id){	
		$this->load->Model('m_kpi');
		$data['item'] = $this->m_kpi->xoa_kpi($id);
		$data['title']= "Thông tin KPI";
		$this->my_layout->view("master/v_xoakpi",$data);		
	}	
	
	public function xoabckpi($id){	
		$this->load->Model('m_ctkpi');
		$data['item'] = $this->m_ctkpi->xoa_bckpi($id);
		$data['title']= "Thông tin KPI";
		$this->my_layout->view("master/v_xoabckpi",$data);		
	}	
	public function setkpi($id){
		$data['title']= "Cài đặt KPI";
		$this->load->Model('m_kpi');
		$data['item'] = $this->m_kpi->my_info($id);	
		$this->load->Model('m_nhanvien');
		$data['info'] = $this->m_nhanvien->person_info();
		$this->my_layout->view("master/v_setkpi",$data);
	}
	
	public function checkkpi($id){
		$data['title'] = "Kiểm tra cài đặt KPI";
		$this->load->Model('m_kpi');
		$data['item'] = $this->m_kpi->my_info($id);
		$this->my_layout->view("master/v_checkkpi",$data);
	}
		// Trang nhân viên 
	
	public function xemnhanvien(){
		$this->load->Model('m_nhanvien');
		
		$config['base_url']   = base_url(). "index.php/home/xemnhanvien";
        $config['total_rows'] = $this->m_nhanvien->count_all();
        $config['per_page']   = 50;
		
	 	$start = $this->uri->segment(3);
        $this->load->library("pagination",$config);
        $data['pagination'] = $this->pagination->create_links();
        $data['info'] = $this->m_nhanvien->listall($config['per_page'],$start);
		
		$data['title'] = "Xem thông tin nhân viên ";		
        $this->my_layout->view('master/c-nhanvien',$data); 		

	}
	
	public function ttnghiphep(){
		$this->load->Model('m_nghiphep');		
		$config['base_url']   = base_url(). "index.php/master/ttnghiphep";
        $config['total_rows'] = $this->m_nghiphep->count_all();
        $config['per_page']   = 50;		
	 	$start = $this->uri->segment(3);
        $this->load->library("pagination",$config);
        $data['pagination'] = $this->pagination->create_links();
        $data['info'] = $this->m_nghiphep->listall($config['per_page'],$start);			
		$data['title'] = "Thông tin ngày nghỉ phép";
		$this->my_layout->view("master/v-nghiphep",$data);
	}
	
	public function ctnghiphep(){
		$this->load->Model('m_ctnghiphep');		
		$config['base_url']   = base_url(). "index.php/master/ctnghiphep";
        $config['total_rows'] = $this->m_ctnghiphep->count_all();
        $config['per_page']   = 50;		
	 	$start = $this->uri->segment(3);
        $this->load->library("pagination",$config);
        $data['pagination'] = $this->pagination->create_links();
        $data['info'] = $this->m_ctnghiphep->listall($config['per_page'],$start);			
		$data['title']= "Quản Lý Nghỉ Phép";
		$this->my_layout->view("master/c-ngaynghi",$data);
	}
	
	public function resetphep(){		
		$this->load->Model('m_nghiphep');		
		$this->m_nghiphep->reset_ngay();		
		$config['base_url']   = base_url(). "index.php/master/ttnghiphep";
        $config['total_rows'] = $this->m_nghiphep->count_all();
        $config['per_page']   = 50;		
	 	$start = $this->uri->segment(3);
        $this->load->library("pagination",$config);
        $data['pagination'] = $this->pagination->create_links();
        $data['info'] = $this->m_nghiphep->listall($config['per_page'],$start);			
		$data['title'] = "Thông tin ngày nghỉ phép";
		$this->my_layout->view("master/v-nghiphep",$data);
	}
	
	public function resetcong(){
		$this->load->Model('m_persondailylog');
		$this->m_persondailylog->xoa_ds();
		$this->load->Model('m_nhanvien');
		$data['item'] = $this->m_nhanvien->person_info();
		$data['title']= "Chấm công";
		$this->my_layout->view("master/v-cong",$data);
	}
	
	public function nghikhongphep(){
		$data['title'] = "Quản lí nghỉ không phép";
		$this->my_layout->view("master/v-khongphep",$data);
	}
	
	public function checkkhongphep(){
		$data['title'] = "Chi tiết nghỉ không phép";
		$this->my_layout->view("master/v-checkphep",$data);
	}
	
	public function xoactphep($id){
		$this->load->Model('m_ctnghiphep');
		$data['item'] = $this->m_ctnghiphep->xoa_phep($id);
		$data['title']= "Chi tiết nghỉ phép";
		$this->my_layout->view("master/v_xoaphep",$data);
	}
}
?>
